<?php
namespace Admin\Controller;

/**
 * 后台订单控制器
 * 
 * @author Ringo Chan<334258471@qq.com>
 */
class CompanyController extends AdminController{
    public function index(){
        $list   = $this->lists('company');
        foreach ($list as $key=>$val) {
            $list[$key]['license'] = M('picture')->where('id='.$val['license'])->getField('path');
        }
        $this->assign('_list', $list);
        $this->meta_title = '商品列表';
        $this->display();
    }
    public function settype(){
    	$id = I('id',0);
    	$type = I('type');
		$data = array('id'=>$id,'type'=>$type);
		$result = M('company')->save($data);
		if ($result) {
			$this->success("操作成功");
		}else{
			$this->error("操作失败");
		}
    }
    public function worklist(){
        $list   = $this->lists('work');
        $this->assign('_list', $list);
        $this->meta_title = '工作列表';
		$this->display();
    }

    /**
     * 查看工作详情
     */
    public function info() {
        $id = I('id');
        $result = M('work')->where('id='.$id)->find();
        $companyInfo = M('company')->where('id='.$result['cid'])->find();
        $result['license'] = M('picture')->where('id='.$companyInfo['license'])->getField('path');
        $result['companyName'] = $companyInfo['company'];
        $this->assign('result', $result);
        $this->display();
    }
    public function pass() {
        $id = I('id');
        $result = M('work')->where('id='.$id)->setField('status', 1);
        $result?$this->success('操作成功'):$this->error('操作失败');
    }
    public function unpass() {
        $id = I('id');
        $result = M('work')->where('id='.$id)->setField('status', 2);
        $result?$this->success('操作成功'):$this->error('操作失败');
    }
}